<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Promise的基本使用</title>
</head>
<body>
    <script>
        const p =new Promise((resolve, reject)=>{
            setTimeout(() => {
               const time = Date.now();
                if(time%2 === 0){
                    resolve('成功的数据, time='+time);
                } else {
                    reject('失败的数据, time'+time);
                }
            }, 1000);
        });

        p.then(value=>{
            console.log('成功的回调', value);
        }, 
        reason =>{
            console.warn('失败的回调', reason);
        })

    </script>
</body>
</html>